<?php

namespace app\common\model;

use think\Model;

/**
 * 卡号产品
 */
class Packages extends Model
{

    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    // 追加属性
    protected $append = [
        'bxhf_text'
    ];
    public function getBxhfTextAttr($value, $data)
    {
        $value = 0;
        if(isset($data['epact_set_meal']) && isset($data['ciyue_set_meal'])){
            $jie_day = date('d');

            if($jie_day > 30){
                $jie_day = 30;
            }
            $value = round((30 - $jie_day)*($data['epact_set_meal']/30));
        }
        return $value;
    }
}
